package dtos

import (
	"errors"
	"log"
	"strconv"

	"cashew.com/cashew_common/constants"
	"github.com/beego/beego/v2/core/validation"
)

func ValidateParams(params interface{}) error {
	valid := validation.Validation{}

	// 进行数据验证
	b, err := valid.Valid(params)
	if err != nil {
		// 处理验证过程中的错误，比如记录日志等
		return err
	}

	if !b {
		for _, err := range valid.Errors {
			log.Println(err.Key, err.Message)
			return errors.New(err.Message)
		}
	}

	return nil
}

type AcceptOrderParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
}

func (aop *AcceptOrderParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	aop.UserId, err = strconv.ParseInt(aop.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

type StopOrderParams struct {
	UserId    int64
	UserIdstr string `json:"user_id"`
}

func (sop *StopOrderParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	sop.UserId, err = strconv.ParseInt(sop.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

//userId, _ := c.GetInt64("user_id")
//gender, _ := c.GetInt("gender")
//isCaller, _ := c.GetInt("is_caller")
//mateUserId, _ := c.GetInt64("mate_user_id")

type WaitCallPageParams struct {
	UserId     string `json:"user_id"`
	Gender     int    `json:"gender"`
	IsCaller   int    `json:"is_caller"`
	MateUserId string `json:"mate_user_id"`
}
type WaitCallPageRes struct {
	Gender      int `json:"gender"`
	PayPrice    int `json:"pay_price"`
	AnchorPrice int `json:"anchor_price"`
}

func (wcpp *WaitCallPageParams) Valid(v *validation.Validation) {
	// 验证 UserId 是否合法
	userId, _ := strconv.ParseInt(wcpp.UserId, 10, 64)
	if wcpp.UserId == "" || userId <= 0 {
		v.SetError("user_id", "用户编号不合法")
	}

	if wcpp.Gender != constants.SEX_MAILE && wcpp.Gender != constants.SEX_FEMALE {
		v.SetError("gender", "性别不合法")
	}

	if wcpp.IsCaller <= 0 {
		v.SetError("is_caller", "拨打用户编号不合法")
	}

	mateUserId, _ := strconv.ParseInt(wcpp.MateUserId, 10, 64)
	if wcpp.MateUserId == "" || mateUserId <= 0 {
		v.SetError("mate_user_id", "通话类型不合法")
	}

	return
}

type AnswerCallParams struct {
	UserId     int64
	UserIdStr  string `json:"user_id"`
	CallUserId string `json:"call_user_id"`
	CallType   int    `json:"call_type"`
	//Gender     int    `json:"gender"`
}
type AnswerCallRes struct {
	Guid string `json:"guid"`
}

func (acp *AnswerCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	acp.UserId, err = strconv.ParseInt(acp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 CallUserId 是否合法
	callUserId, _ := strconv.ParseInt(acp.CallUserId, 10, 64)
	if acp.CallUserId == "" || callUserId <= 0 {
		_ = v.SetError("call_user_id", "拨打用户编号不合法")
		return
	}

	// 验证CallType是否合法，这里可以根据你的具体业务需求添加更多条件
	if acp.CallType < 0 || acp.CallType > 2 {
		_ = v.SetError("call_type", "通话类型不合法")
		return
	}

	//if acp.Gender != constants.SEX_MAILE && acp.Gender != constants.SEX_FEMALE {
	//	_ = v.SetError("gender", "性别不合法")
	//	return
	//}

	return
}

type ConfirmCallParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	Gender    int    `json:"gender"`
	ToUserId  string `json:"to_userId"`
	Guid      string `json:"guid"`
}

func (ccp *ConfirmCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	ccp.UserId, err = strconv.ParseInt(ccp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	if ccp.Gender != constants.SEX_MAILE && ccp.Gender != constants.SEX_FEMALE {
		_ = v.SetError("gender", "性别不合法")
		return
	}

	// 验证 ToUserId 是否合法
	toUserId, _ := strconv.ParseInt(ccp.ToUserId, 10, 64)
	if ccp.ToUserId == "" || toUserId <= 0 {
		_ = v.SetError("to_userId", "通知用户编号不合法")
		return
	}

	// 验证 Guid 是否合法
	guid, _ := strconv.ParseInt(ccp.Guid, 10, 64)
	if ccp.Guid == "" || guid <= 0 {
		_ = v.SetError("guid", "本次通话唯一标识不合法")
		return
	}

	return
}

type StopCallParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	ToUserId  string `json:"to_user_id"`
	CallerId  string `json:"caller_id"`
	//Gender        int    `json:"gender"`
	Guid          string `json:"guid"`
	OperationType int    `json:"operation_type"`
}

func (scp *StopCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	scp.UserId, err = strconv.ParseInt(scp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 ToUserId 是否合法
	toUserId, _ := strconv.ParseInt(scp.ToUserId, 10, 64)
	if scp.ToUserId == "" || toUserId <= 0 {
		_ = v.SetError("to_user_id", "通知用户编号不合法")
		return
	}

	//
	// 验证 CallerId 是否合法
	callerId, _ := strconv.ParseInt(scp.CallerId, 10, 64)
	if scp.CallerId == "" || callerId <= 0 {
		_ = v.SetError("caller_id", "发起对聊用户编号不合法")
		return
	}

	// 验证 Guid 是否合法（ Guid 可以为空，表示是未接听的挂断）
	guid, _ := strconv.ParseInt(scp.Guid, 10, 64)
	if scp.Guid != "" && guid < 0 {
		_ = v.SetError("guid", "本次通话唯一标识不合法")
		return

	}

	//// 验证 Gender 是否合法
	//if scp.Gender != constants.SEX_MAILE && scp.Gender != constants.SEX_FEMALE {
	//	_ = v.SetError("Sex", "挂电话类型不合法")
	//	return
	//}
	return
}

type InterruptsCallParams struct {
	UserId        int64
	UserIdStr     string `json:"user_id"`
	AnchorId      string `json:"anchor_id"`
	Guid          string `json:"guid"`
	OperationType int    `json:"operation_type"`
}

func (icp *InterruptsCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	icp.UserId, err = strconv.ParseInt(icp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 AnchorId 是否合法
	anchorId, _ := strconv.ParseInt(icp.AnchorId, 10, 64)
	if icp.AnchorId == "" || anchorId <= 0 {
		_ = v.SetError("anchor_id", "主播编号不合法")
		return
	}

	// 验证 Guid 是否合法
	guid, _ := strconv.ParseInt(icp.Guid, 10, 64)
	if icp.Guid == "" || guid <= 0 {
		_ = v.SetError("Guid", "本次通话唯一标识不合法")
		return
	}

	// 验证 OperationType 是否合法（目前只有1一种类型）
	if icp.OperationType != 1 {
		_ = v.SetError("Guid", "操作类型不合法")
		return
	}

	return
}

type LivingOrderStatusSettingParams struct {
	UserId    int64
	UserIdstr string `json:"user_id"`
	LiveModel int    `json:"live_model"`
}

func (lossp *LivingOrderStatusSettingParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	lossp.UserId, err = strconv.ParseInt(lossp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 LiveModel 是否合法
	if lossp.LiveModel != constants.LIVE_MODEL_LEAVE && lossp.LiveModel != constants.LIVE_MODEL_LIVE_PLUS && lossp.LiveModel != constants.LIVE_MODEL_LIVE_ONLY {
		_ = v.SetError("live_model", "直播模式字段不合法")
		return
	}
	return
}

type ObtainIncomeParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	Guid      string `json:"guid"`
}

func (oip *ObtainIncomeParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	oip.UserId, err = strconv.ParseInt(oip.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 Guid 是否合法
	guid, _ := strconv.ParseInt(oip.Guid, 10, 64)
	if oip.Guid == "" || guid <= 0 {
		_ = v.SetError("guid", "本次通话唯一标识不合法")
		return
	}
	return
}

//type AnswerCallParams struct {
//	UserId         string `json:"user_id"`
//	CallUserId     string `json:"call_user_id"`
//	CallType       int    `json:"call_type"`
//	Gender         int    `json:"gender"`
//	IfMaleGoldCoin int64  `json:"if_male_gold_coin"`
//}
//type AnswerCallRes struct {
//	Guid int64 `json:"guid"`
//}
//
//func (acp *AnswerCallParams) Valid(v *validation.Validation) {
//	// 验证 UserId 是否合法
//	userId, _ := strconv.ParseInt(acp.UserId, 10, 64)
//	if acp.UserId == "" || userId <= 0 {
//		v.SetError("user_id", "接听用户编号不合法")
//	}
//
//	// 验证 CallUserId 是否合法
//	callUserId, _ := strconv.ParseInt(acp.CallUserId, 10, 64)
//	if acp.CallUserId == "" || callUserId <= 0 {
//		v.SetError("call_user_id", "拨打用户编号不合法")
//	}
//
//	// 验证CallType是否合法，这里可以根据你的具体业务需求添加更多条件
//	if acp.CallType < 0 || acp.CallType > 2 {
//		v.SetError("call_type", "通话类型不合法")
//	}
//
//	if acp.Gender != constants.SEX_MAILE && acp.Gender != constants.SEX_FEMALE {
//		v.SetError("gender", "性别不合法")
//	}
//
//	return
//}

type CallParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	ToUserId  string `json:"to_user_id"`
	//Gender    int    `json:"gender"`
	CallType int `json:"call_type"`
}

func (oip *CallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	oip.UserId, err = strconv.ParseInt(oip.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 ToUserId 是否合法
	toUserId, _ := strconv.ParseInt(oip.ToUserId, 10, 64)
	if oip.ToUserId == "" || toUserId <= 0 {
		_ = v.SetError("gold_coin", "用户编号不合法")
		return
	}

	//if oip.Gender != constants.SEX_MAILE && oip.Gender != constants.SEX_FEMALE {
	//	_ = v.SetError("gender", "性别不合法")
	//	return
	//}

	if oip.CallType != constants.CALL_TYPE_ACTIVE && oip.CallType != constants.CALL_TYPE_RANDOM_MATCH && oip.CallType != constants.CALL_TYPE_RECOMMENDED {
		_ = v.SetError("call_type", "呼叫类型不合法")
		return
	}
	return
}

type QuickCallParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
}

func (qcp *QuickCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	qcp.UserId, err = strconv.ParseInt(qcp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

type CancelQuickCallParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
}

func (cqcp *CancelQuickCallParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	cqcp.UserId, err = strconv.ParseInt(cqcp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

// 收益结算数据获取 结果结构体
type ObtainIncomeRes struct {
	Guid           string `json:"guid"`
	AnchorId       string `json:"anchor_id"`
	ViewerId       string `json:"viewer_id"`
	BeginTime      string `json:"begin_time"`
	EndTime        string `json:"end_time"`
	CallType       int    `json:"call_type"`
	DurationIncome int    `json:"duration_income"`
	GiftIncome     string `json:"gift_income"`
}

type QuickCallRes struct {
	AnchorId    string `json:"anchor_id"`
	Status      int    `json:"status"`
	SubRegionId int    `json:"sub_region_id"`
}

type GetFreeChatCountParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	ToUserId  string `json:"to_user_id"`
}

type GetFreeChatCountRes struct {
	UserId       string `json:"user_id"`
	Identity     int    `json:"identity"`
	FreeCount    int    `json:"free_count"`
	BlackStatus  int    `json:"black_status"`
	ChatUnlock   bool   `json:"chat_unlock"`
	ChatPayPrice int64  `json:"chat_pay_price"`
}

func (gfccp *GetFreeChatCountParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	gfccp.UserId, err = strconv.ParseInt(gfccp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 ToUserId 是否合法
	toUserId, _ := strconv.ParseInt(gfccp.ToUserId, 10, 64)
	if gfccp.ToUserId == "" || toUserId <= 0 {
		_ = v.SetError("to_user_id", "消息接收者编号不合法")
		return
	}

	return
}

type SendChatParams struct {
	UserId    int64
	UserIdstr string `json:"user_id"`
	//Gender       int    `json:"gender"`
	FromType     int    `json:"from_type"`
	ToUserId     string `json:"to_user_id"`
	MsgType      int    `json:"msg_type"`
	Msg          string `json:"msg"`
	Duration     int    `json:"duration"`
	ChatScenario int    `json:"chat_scenario"`
}

type Odds struct {
	Addcoin  int `json:"addcoin"`
	Sum      int `json:"sum"`
	Odds10   int `json:"odds10"`
	Odds50   int `json:"odds50"`
	Odds500  int `json:"odds500"`
	Odds1000 int `json:"odds1000"`
	PropId   int `json:"prop_id"`
}

type SendChatRes struct {
	ChatUnlock   bool  `json:"chat_unlock"`
	ChatPayPrice int64 `json:"chat_pay_price"`
	Identity     int   `json:"identity"`
	FreeCount    int   `json:"free_count"`
	SendStatus   bool  `json:"send_status"`
}

func (scp *SendChatParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	scp.UserId, err = strconv.ParseInt(scp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}
	// 验证 ToUserId 是否合法
	toUserId, _ := strconv.ParseInt(scp.ToUserId, 10, 64)
	if scp.ToUserId == "" || toUserId <= 0 {
		_ = v.SetError("to_user_id", "消息接收者编号不合法")
		return
	}

	// FromType
	if scp.FromType != constants.MSG_FROM_TYPE_USER && scp.FromType != constants.MSG_FROM_TYPE_SYS {
		_ = v.SetError("from_type", "消息来源不合法")
		return
	}

	if scp.MsgType != constants.CHAT_MSG_TYPE_TEXT && scp.MsgType != constants.CHAT_MSG_TYPE_PIC && scp.MsgType != constants.CHAT_MSG_TYPE_AUDIO && scp.MsgType != constants.CHAT_MSG_TYPE_VIDEO && scp.MsgType != constants.CHAT_MSG_TYPE_GIFT {
		_ = v.SetError("msg_type", "消息类型不合法")
		return
	}

	//if scp.Gender != constants.SEX_MAILE && scp.Gender != constants.SEX_FEMALE {
	//	_ = v.SetError("gender", "性别不合法")
	//	return
	//}

	if scp.Msg == "" {
		_ = v.SetError("msg", "消息内容不能为空")
		return
	}
	if scp.ChatScenario != constants.CHAT_SCENARIO_VIDEO_CALL && scp.ChatScenario != constants.CHAT_SCENARIO_PRIVATE {
		_ = v.SetError("msg", "聊天场景不合法")
		return
	}

	return
}

type SendGiftRes struct {
	ChatUnlock   bool  `json:"chat_unlock"`
	ChatPayPrice int64 `json:"chat_pay_price"`
	//Odds         Odds  `json:"odds"`
}

type PaychatUnlockParams struct {
	UserId    int64
	UserIdstr string `json:"user_id"`
	AnchorId  string `json:"anchor_id"`
	Amount    int    `json:"amount"`
}

func (pup *PaychatUnlockParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	pup.UserId, err = strconv.ParseInt(pup.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 AnchorId 是否合法
	anchorId, _ := strconv.ParseInt(pup.AnchorId, 10, 64)
	if pup.AnchorId == "" || anchorId <= 0 {
		_ = v.SetError("anchor_id", "主播编号不合法")
		return
	}

	// 验证 Amount 是否合法
	if pup.Amount <= 0 {
		_ = v.SetError("amount", "所属大区编号不合法")
		return
	}

	return
}

type WsConnectParams struct {
	UserId      int64
	UserIdstr   string `json:"user_id"`
	Gender      int    `json:"gender"`
	CountryCode string `json:"country_code"`
	Nick        string `json:"nick"`
	HeadImg     string `json:"head_img"`
	Age         int    `json:"age"`
}

func (scp *WsConnectParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	scp.UserId, err = strconv.ParseInt(scp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证Gender是否合法
	if scp.Gender != constants.SEX_MAILE && scp.Gender != constants.SEX_FEMALE {
		_ = v.SetError("UserId", "用户性别不合法")
		return
	}

	// 验证 CountryCode 是否合法
	if scp.CountryCode == "" {
		_ = v.SetError("RegionId", "所属国家编号不合法")
		return
	}

	return
}

type WsDisconnectParams struct {
	UserId    int64
	UserIdstr string `json:"user_id"`
	//Gender    int    `json:"gender"`
}

func (wdp *WsDisconnectParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	wdp.UserId, err = strconv.ParseInt(wdp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	//// 验证Gender是否合法
	//if wdp.Gender != constants.SEX_MAILE && wdp.Gender != constants.SEX_FEMALE {
	//	v.SetError("UserId", "用户性别不合法")
	//}

	return
}

type VideocallUpdateBlackParams struct {
	UserId        int64
	UserIdstr     string `json:"user_id"`
	DistUserId    int64
	DistUserIdstr string `json:"dist_user_id"`
	Sex           int    `json:"sex"`
	Status        int    `json:"status"`
}

func (vubp *VideocallUpdateBlackParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	vubp.UserId, err = strconv.ParseInt(vubp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	if vubp.UserId <= 0 {
		_ = v.SetError("UserId", "用户编号必须是正整数")
		return
	}

	// 验证AnchorId是否合法
	vubp.DistUserId, err = strconv.ParseInt(vubp.DistUserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("DistUserId", "主播编号不合法")
		return
	}

	if vubp.DistUserId <= 0 {
		_ = v.SetError("DistUserId", "主播编号必须是正整数")
		return
	}

	if vubp.UserId == vubp.DistUserId {
		_ = v.SetError("DistUserId", "不能拉黑自己")
		return
	}

	if vubp.Sex != constants.SEX_MAILE && vubp.Sex != constants.SEX_FEMALE {
		_ = v.SetError("Sex", "性别错误")
		return
	}

	// 验证Status是否合法
	if vubp.Status != constants.BLACKLIST_STATUS_BLOCKED && vubp.Status != constants.BLACKLIST_STATUS_UNBLOCKED {
		_ = v.SetError("AnchorId", "拉黑状态错误")
		return
	}
}

type VideocallGetBlacklistParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	Page      int    `json:"page"`
}

func (vgblp *VideocallGetBlacklistParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	vgblp.UserId, err = strconv.ParseInt(vgblp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	if vgblp.UserId <= 0 {
		_ = v.SetError("UserId", "用户编号必须是正整数")
		return
	}

	if vgblp.Page <= 0 {
		_ = v.SetError("Page", "页码必须是正整数")
		return
	}
}

type VideocallGetBlacklistResult struct {
	Page PageData        `json:"page"`
	List []BlacklistItem `json:"list"`
}

type PageData struct {
	CurrentPage int `json:"current_page"`
	PerPage     int `json:"per_page"`
	TotalPages  int `json:"total_pages"`
	TotalItems  int `json:"total_items"`
}

type BlacklistItem struct {
	UserId     int64  `json:"user_id"`
	Nick       string `json:"nick"`
	HeadImg    string `json:"head_img"`
	CreateTime int    `json:"create_time"`
}

type VideocallGetIsBlackDistPrams struct {
	UserId        int64
	UserIdstr     string `json:"user_id"`
	Sex           int    `json:"sex"`
	DistUserId    int64
	DistUserIdstr string `json:"dist_user_id"`
}

func (vgibp *VideocallGetIsBlackDistPrams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	vgibp.UserId, err = strconv.ParseInt(vgibp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	if vgibp.UserId <= 0 {
		_ = v.SetError("UserId", "用户编号必须是正整数")
		return
	}

	// 验证AnchorId是否合法
	vgibp.DistUserId, err = strconv.ParseInt(vgibp.DistUserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("DistUserId", "DistUserId编号不合法")
		return
	}

	if vgibp.DistUserId <= 0 {
		_ = v.SetError("DistUserId", "DistUserId必须是正整数")
		return
	}

	if vgibp.UserId == vgibp.DistUserId {
		_ = v.SetError("DistUserId", "不能查询自己拉黑状态")
		return
	}
}

type VideocallGetIsBlackDistResult struct {
	Status int `json:"status"`
}

type VideocallEvaluateParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	Guid      string `json:"guid"`
	Type      int    `json:"type"`
}

func (vep *VideocallEvaluateParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	vep.UserId, err = strconv.ParseInt(vep.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	if vep.UserId <= 0 {
		_ = v.SetError("UserId", "用户编号必须是正整数")
		return
	}

	guid, _ := strconv.ParseInt(vep.Guid, 10, 64)
	if vep.Guid == "" || guid <= 0 {
		_ = v.SetError("CallId", "通话编号必须是正整数")
		return
	}

	if !constants.ValidateEvaluate(vep.Type) {
		_ = v.SetError("Type", "评价类型错误")
		return
	}
}

type SendGiftParams struct {
	UserId       int64
	UserIdstr    string `json:"user_id"`
	ToUserId     string `json:"to_user_id"`
	PropId       int    `json:"prop_id"`
	PropNum      int    `json:"prop_num"`
	Guid         string `json:"guid"`
	ChatScenario int    `json:"chat_scenario"`
}

func (sgp *SendGiftParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	sgp.UserId, err = strconv.ParseInt(sgp.UserIdstr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	// 验证 ToUserId 是否合法
	anchorId, _ := strconv.ParseInt(sgp.ToUserId, 10, 64)
	if sgp.ToUserId == "" || anchorId <= 0 {
		_ = v.SetError("to_user_id", "主播编号不合法")
		return
	}

	// 验证 GiftId 是否合法
	if sgp.PropId <= 0 {
		_ = v.SetError("prop_id", "礼物编号不合法")
		return
	}

	// 验证 PropNum 是否合法
	if sgp.PropNum <= 0 {
		_ = v.SetError("prop_num", "礼物数量不合法")
		return
	}

	if sgp.ChatScenario != constants.CHAT_SCENARIO_VIDEO_CALL && sgp.ChatScenario != constants.CHAT_SCENARIO_PRIVATE {
		_ = v.SetError("msg", "聊天场景不合法")
		return
	}

	// 验证 Guid 是否合法
	guid, _ := strconv.ParseInt(sgp.Guid, 10, 64)
	if sgp.ChatScenario == constants.CHAT_SCENARIO_VIDEO_CALL {
		// 对聊场景，Guid不能为空
		if sgp.Guid == "" || guid < 0 {
			_ = v.SetError("guid", "guid不能为空")
			return
		}
	} else {
		// 私聊场景，guid可以为空
		if sgp.Guid != "" && guid <= 0 {
			_ = v.SetError("guid", "guid不合法")
			return
		}
	}

	return
}

type CocoRes struct {
	Result int         `json:"result"`
	Msg    string      `json:"msg"`
	Data   interface{} `json:"data"`
}

// KeepaliveParams
type KeepAliveParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
	//Gender    int    `json:"gender"`
}

func (kp *KeepAliveParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	kp.UserId, err = strconv.ParseInt(kp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	//// 验证 Gender 是否合法
	//if kp.Gender != constants.SEX_MAILE && kp.Gender != constants.SEX_FEMALE {
	//	_ = v.SetError("gender", "性别不合法")
	//	return
	//}

	return
}

type AnchorPriceInfoRes struct {
	PriceType   int   `json:"price_type"`
	PayPrice    int64 `json:"pay_price"`
	AnchorPrice int64 `json:"anchor_price"`
}

type SubmitTaskToPoolParams struct {
	UserId     int64
	UserIdStr  string `json:"user_id"`
	SubmitType int    `json:"submit_type"`
	Msg        string `json:"msg"`
}

func (sttpp *SubmitTaskToPoolParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	sttpp.UserId, err = strconv.ParseInt(sttpp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

type TestAddUserToAnchorMatchPoolParams struct {
	UserId    int64
	UserIdStr string `json:"user_id"`
}

func (taupp *TestAddUserToAnchorMatchPoolParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	taupp.UserId, err = strconv.ParseInt(taupp.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	return
}

// UserInfoParams
type UserInfoParams struct {
	UserId       int64
	UserIdStr    string `json:"user_id"`
	FilterUserId string `json:"filter_user_id"`
}

type UserInfoRes struct {
	UserId      int64  `json:"user_id"`
	Identity    int    `json:"identity"`
	Gender      int    `json:"gender"`
	Status      int    `json:"status"`
	SubRegionId int    `json:"sub_region_id"`
	Nick        string `json:"nick"`
	HeadImg     string `json:"head_img"`
	Age         int    `json:"age"`
	FlagImage   string `json:"flag_image"`
}

func (uip *UserInfoParams) Valid(v *validation.Validation) {
	// 验证UserId是否合法
	var err error
	uip.UserId, err = strconv.ParseInt(uip.UserIdStr, 10, 64)

	if err != nil {
		_ = v.SetError("UserId", "用户编号不合法")
		return
	}

	filterUserId, err := strconv.ParseInt(uip.FilterUserId, 10, 64)
	if err != nil || filterUserId <= 0 {
		_ = v.SetError("msg", "查询用户编号不合法")
		return
	}

	return
}
